package com.example.huoher.miniaddressbook;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.LinkedList;

public class PersonAdapter extends BaseAdapter {

    private LinkedList<Person> personLinkedList;
    private Context mContext;

    public PersonAdapter(LinkedList<Person> personLinkedList, Context mContext) {
        this.personLinkedList = personLinkedList;
        this.mContext = mContext;
    }

    @Override
    public int getCount() {
        return personLinkedList.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        view = LayoutInflater.from(mContext).inflate(R.layout.list_item,viewGroup,false);
        TextView textView1 = view.findViewById(R.id.name);
        TextView textView2 = view.findViewById(R.id.says);

        textView1.setText(personLinkedList.get(i).getName());
        textView2.setText(personLinkedList.get(i).getNumber());
        return view;
    }
}
